Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

feat(spec): log URL in error when attempting XHR from FakeAsyncTestZone #893

Merged
merged 1 commit into from
Sep 6, 2017

Conversation

vikerman
Copy link
Contributor

@vikerman vikerman commented Sep 5, 2017

Save the URL from xhr.open and log it when throwing an error from FakeAsyncTestZone when the XHR send it attempted. This would make it easier to debug such errors from a fakeAsync test.

Save the URL from xhr.open and log it when throwing an error from FakeAsyncTestZone when the XHR send it attempted. This would make it easier to debug such errors from a fakeAsync test.
throw new Error('Cannot make XHRs from within a fake async test.');
throw new Error(
'Cannot make XHRs from within a fake async test. Request URL: ' +
(task.data as any)['url']);
Copy link
Collaborator

@JiaLiPassion JiaLiPassion Sep 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vikerman , if we get the url from task.data, maybe we can get the url by directly calling 'task.data.target.responseURL? So we don't need to save an additional urlinxhrandtask.data`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my testing responseURL is an empty string before the actual request is sent.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vikerman , yes, you are right!

Copy link
Member

@juliemr juliemr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! This'll help debugging tons.

@mhevery mhevery merged commit 874bfdc into angular:master Sep 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants